<%@page import="com.lrf.freeshipping.bean.PageBean"%>
<%@page import="com.lrf.freeshipping.tool.Common"%>
<%@page import="com.lrf.freeshipping.service.ProductOption"%>
<%@page import="com.lrf.freeshipping.bean.ProductListBean"%>
<%@page import="com.lrf.freeshipping.jdbc.SQLConstant"%>
<%@page import="com.lrf.freeshipping.jdbc.JDBCOption"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>商品信息</title>
    <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
     <link rel="shortcut icon" type="image/x-icon" href="assets/image/favicon.ico" />

    <link rel="stylesheet" type="text/css" href="css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="css/theme.css">
    <link rel="stylesheet" href="css/font-awesome.css">

    <script src="js/jquery-1.8.1.min.js" type="text/javascript"></script>
    
    <script type="text/javascript">
      function deleteProduct(productID) {
	    var se=confirm("确定删除该商品？");
	    if(se==true){
	    	top.location="delete?product_id="+productID;
	    }else{
	    	window.back();
	    }
	}
    </script>
     
     
     
    <style type="text/css">
        #line-chart {
            height:300px;
            width:800px;
            margin: 0px auto;
            margin-top: 1em;
        }
        .brand { font-family: georgia, serif; }
        .brand .first {
            color: #ccc;
            font-style: italic;
        }
        .brand .second {
            color: #fff;
            font-weight: bold;
        }
    </style>
    
</head>


 <body> 
    <jsp:include page="head.jsp"/>
     <!-- 检查是否是登录状态 -->
    <jsp:include page="check-sign-in.jsp"></jsp:include>
    <div class="container-fluid">
        
        <div class="row-fluid">
            <!-- 引入左菜单栏 -->
            <jsp:include page="left-menu.jsp" flush="true"></jsp:include>
        <div class="span9">
            <h1 class="page-title" style="width:100%">商品列表
            <div style="float:right;">
              <a href="add-production.jsp" class="btn btn-primary"><i class="icon-plus"></i>新商品</a>
              <button class="btn">Import</button>
              <button class="btn">Export</button>            
            </div>
            </h1>   
<div class="well">
    <table class="table">
      <thead>
        <tr>
          <th>序号</th>
          <th>图片</th>
          <th>卖价</th>
		  <th>佣金</th>
          <th>入库时间</th>
		  <th>下架时间</th>
          <th style="width: 26px;"></th>
        </tr>
      </thead>
      <tbody>
      <%
         int currentPage;
        if(request.getParameter("page")==null) currentPage = 1;
        else currentPage = Integer.valueOf(request.getParameter("page"));
        PageBean pageBean = (PageBean)session.getAttribute("pageBean");
        pageBean.setCurrentPage(currentPage);
        session.setAttribute("pageBean", pageBean);
        String tag=null;
        tag = request.getParameter("tag");
        List list=null;
        if(tag ==null) {
        	tag="";
        }else{
        	list = JDBCOption.query(SQLConstant.queryProductByType1,"%"+tag+"%");
        	int productNumber = list.size();
    		pageBean.setPageUnmber(productNumber%pageBean.getPageSize()==0?productNumber/pageBean.getPageSize():productNumber/pageBean.getPageSize()+1);
    		pageBean.setProductNumber(productNumber);
        }   		
        List<ProductListBean> beans = ProductOption.packageForProductList("%"+tag+"%", 
        		pageBean.getCurrentPage()-1, pageBean.getPageSize()); 
        ProductListBean bean; 
        for(int i=0;i<beans.size();i++){
        	bean = beans.get(i);       	
       %>
        <tr>
          <td><%=bean.getId()%></td>
          <td>
             <a href="<%=bean.getProductUrl()%>">
               <img src="<%=bean.getImageUrl()%>" height="60" width="60">
             </a>
          </td>
          <td><%="US $"+bean.getSalePrice()%></td>
          <td><%=bean.getCommission()%></td>
		  <td><%=bean.getAddTime()%></td>
		  <td><%=bean.getValidTime()%></td>
          <td>
              <a href="modify-product.jsp?product_id=<%=bean.getProductId()%>"><i class="icon-pencil"></i></a> &nbsp;&nbsp;&nbsp;&nbsp;
              <a role="button" onclick="deleteProduct(<%=bean.getProductId()%>)"><i class="icon-remove"></i></a>
          
          </td>
        </tr>
       <%}%>
      </tbody>
    </table>
</div>
<div class="pagination">
    <ul>
        <li><a href="product.jsp?tag=<%=tag%>&page=<%=1==pageBean.getCurrentPage()?1:pageBean.getCurrentPage()-1%>">Prev</a></li>
        <li><a href="product.jsp?tag=<%=tag%>&page=1">1</a></li>
        <li><a href="product.jsp?tag=<%=tag%>&page=2">2</a></li>
        <li><a href="product.jsp?tag=<%=tag%>&page=3">3</a></li>
        <li><a href="product.jsp?tag=<%=tag%>&page=4">4</a></li>
        <li><a href="product.jsp?tag=<%=tag%>&page=<%=pageBean.getCurrentPage()==pageBean.getPageUnmber()?pageBean.getCurrentPage():pageBean.getCurrentPage()+1%>">Next</a></li>
    </ul>
    
    <ul style="float: right">
        <li>第<%=pageBean.getCurrentPage()%>页</li>
        <li> / 共<%=pageBean.getPageUnmber()%>页</li>
    </ul>
</div>

<%-- <div class="modal small hide fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 id="myModalLabel">Delete Confirmation</h3>
    </div>
    <div class="modal-body">
        <p class="error-text"><i class="icon-warning-sign modal-icon"></i>Are you sure you want to delete the user?</p>
    </div>
    <div class="modal-footer">
        <button class="btn" data-dismiss="modal" aria-hidden="true">取消</button>
        <a href="delete?page=<%=productId%>" class="btn btn-danger" data-dismiss="modal">删除</a>       
    </div>
</div> --%>

        </div>
    </div>
    

    
    <footer>
        <hr>
        
        <p class="pull-right">develop from <a href="#" title="iwenkeji" target="_blank">iwenkeji</a></p>
        
        
        <p>&copy; 2015 <a href="#">跨进电商</a></p>
    </footer>
    

    

    <!-- Le javascript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="js/bootstrap.js"></script>
    
   
  </body>
</html>



